package log;

import java.io.FileOutputStream;
import java.text.DateFormat;
import java.util.Date;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Section;
import com.itextpdf.text.pdf.PdfWriter;



public class LogPDF {
	private static String FILE = "C:/Users/Mario/Documents/Maestria/tema/LogPdf.pdf";
	private LogPDF pdf= new LogPDF(); 
	
	public void creaPDF(String fecha){
	try {
		Document document = new Document();
		PdfWriter.getInstance(document, new FileOutputStream(FILE));
		document.open();
		addMetaData(document);
		addTitlePage(document);
		addContent(document);
		document.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
	}
	
	private static void addMetaData(Document document) {
		document.addTitle("Log PDF");
		document.addSubject("GreenHouse");
		document.addKeywords("Java, PDF, iText");
		document.addAuthor("ISC Ana Fabiola Anzures");
		document.addCreator("ISC Ana Fabiola Anzures");
	}
	
	private static void addTitlePage(Document document) throws DocumentException{
		Paragraph preface = new Paragraph();
		// We add one empty line
//		addEmptyLine(preface, 1);
		// Lets write a big header
		preface.add(new Paragraph("Log"));

	//	addEmptyLine(preface, 1);
		// Will create: Report generated by: _name, _date
		preface.add(new Paragraph(
				"Report generated by: " + System.getProperty("user.name") + ", " + new Date() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
				));
		//addEmptyLine(preface, 3);
		document.add(preface);
		// Start a new page
		document.newPage();
	}
	
	private static void addContent(Document document) throws DocumentException {		
		Paragraph conten= new Paragraph();
		conten.add(new Paragraph(new Log().sFecha));
		document.add(conten);
	}
	
	
	
	public static String execLogPDF(String a){
		static String b=a;
		//this.a == a;ps
		return b;
		//En vez de System ponerlo en una variable tipo String
		/*Date fecha = new Date();
		System.out.println("");
		//System.out.print("["+fecha.getDay()+"-"+fecha.getMonth()+"-"+fecha.getYear()+" "+fecha.getHours()+":"+fecha.getMinutes()+":"+fecha.getSeconds()+"] - ");
		System.out.print("["+fecha+"] - ");*/
	}
}
